//
//  SanView.m
//  Sports-Go
//
//  Created by rimi on 16/9/22.
//  Copyright © 2016年 YRL. All rights reserved.
//
#define RGBA(r,g,b,a)      [UIColor colorWithRed:(float)r/255.0f green:(float)g/255.0f blue:(float)b/255.0f alpha:a]
#import "SanView.h"

@implementation SanView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addPointer];
    }
    return self;
}
-(void)addPointer{
    //三角形
    UIBezierPath *path = [UIBezierPath bezierPath];
    
    [path moveToPoint:CGPointMake(0, -(self.frame.size.height)/2.0 + (17/2.0))];
    [path addLineToPoint:CGPointMake(-10, -(self.frame.size.height)/2.0 + (17/2.0) + 10)];
    [path addLineToPoint:CGPointMake(10, -(self.frame.size.height)/2.0 + (17/2.0) + 10)];
    [path moveToPoint:CGPointMake(0, -(self.frame.size.height)/2.0 + (17/2.0))];
    
    //使用applyTransform函数来转移坐标的Transform，这样我们不用按照实际显示做坐标计算
    [path applyTransform:CGAffineTransformMakeTranslation(self.frame.size.width*0.5, self.frame.size.height*0.5)];
    
    CAShapeLayer *layer = [CAShapeLayer layer];
    layer.path = path.CGPath;
    layer.fillColor = [UIColor whiteColor].CGColor;
    [self.layer addSublayer:layer];
    
    
    //圆形°
    UIBezierPath *circlePath = [UIBezierPath bezierPath];
    [circlePath addArcWithCenter:CGPointMake(0, -(self.frame.size.height)/2.0 + (17/2.0) + 10 + 10) radius:10 startAngle:(3/2*M_PI) endAngle:(3/2*M_PI + 2*M_PI) clockwise:YES];
    
    //使用applyTransform函数来转移坐标的Transform，这样我们不用按照实际显示做坐标计算
    [circlePath applyTransform:CGAffineTransformMakeTranslation(self.frame.size.width*0.5, self.frame.size.height*0.5)];
    
    CAShapeLayer *circleLayer = [CAShapeLayer layer];
    circleLayer.path = circlePath.CGPath;
    circleLayer.fillColor = RGBA(58, 201, 250, 1).CGColor;
    [self.layer addSublayer:circleLayer];
}
@end
